<%@ page contentType="text/html; charset=utf-8"  pageEncoding="utf-8"%>
<%@ page language="java"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common/meta.jsp"%>
<%@ include file="/common/common.jsp"%>

<script type="text/javascript">
ajaxAction="${ctx}";
	<s:if test="contentAttach!=null&&contentAttach.contentType!=null">
	$("input[name=flag]",window.parent.document).val('<s:property value="contentAttach.contentType"/>');
		<s:if test="contentAttach.contentType.equals(\"content\")">
			$("input[name=content.contentId]",window.parent.document).val('<s:property value="contentAttach.content.contentId"/>');
		</s:if>
		<s:if test="contentAttach.contentType.equals(\"video\")">
			$("input[name=videoContent.contentId]",window.parent.document).val('<s:property value="contentAttach.content.contentId"/>');
		</s:if>
		<s:if test="contentAttach.contentType.equals(\"software\")">
			$("input[name=softwareContent.contentId]",window.parent.document).val('<s:property value="contentAttach.content.contentId"/>');
		</s:if>
		<s:if test="contentAttach.contentType.equals(\"picture\")">
			$("input[name=pictureContent.contentId]",window.parent.document).val('<s:property value="contentAttach.content.contentId"/>');
		</s:if>
		<s:if test="contentAttach.contentType.equals(\"flash\")">
		$("input[name=flashContent.contentId]",window.parent.document).val('<s:property value="contentAttach.content.contentId"/>');
		</s:if>
	</s:if>
	<s:if test="uploadType!=null&&uploadType.equals(\"2\")">
	if(window.XMLHttpRequest){
	       xmlHttp = new XMLHttpRequest();
	}else{
	    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlHttp.onreadystatechange = suf;
    xmlHttp.open("POST", "contentattach-ajaxRequest.action", true);
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.send("control=addFile&contentAttach.content.contentId=<s:property value="contentAttach.content.contentId"/>");
    function suf(){
    	if (xmlHttp.readyState == 4) {
        	$('#uploads',window.parent.document).html('');
            var tt = xmlHttp.responseText;
            if(tt!=null){
         	   $('#uploads',window.parent.document).html(tt.replace(/(value=\").+\"/i,"$1\""));
            }
       }
    }
	</s:if>
	<s:else>
	addFileParent('<s:property value="contentAttach.content.contentId"/>');
	</s:else>
	
</script>

